package com.example.administrator.myapplication;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        requestWindowFeature(Window.FEATURE_NO_TITLE);
        SharedPreferences s = getSharedPre();
        boolean b = s.getBoolean("main",false);
        if (b){
            startActivity(new Intent(this,Main2Activity.class));
        }else {
            final Intent it = new Intent(this, Main3Activity.class); //你要转向的Activity
            Timer timer = new Timer();
            TimerTask task = new TimerTask() {
                @Override
                public void run() {
                    startActivity(it); //执行
                    finish();
                }
            };
            timer.schedule(task, 1000);
        }
        
        finish();
    }




    public SharedPreferences getSharedPre(){
        //获取上下文  再获取共享首选项
        return  getSharedPreferences("loginnew", Context.MODE_PRIVATE);
    }
}
